#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "Model.h"
#include "ItemModifyDlg.h"

#include <QApplication>
#include <QMainWindow>
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QDebug>
#include <QTimer>
#include <QMessageBox>
#include <QTableView>
#include <QHeaderView>
#include <QStandardItemModel>
#include <QSystemTrayIcon>
#include <QMenu>

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

public Q_SLOTS:
    void OnSetWebdavCfgFinished(int workerIndex, bool succeed, const WorkerModel::WebdavCfg &cfg);
    void OnWorkerStateChanged(int workerIndex, WorkerModel::State s);

private Q_SLOTS:
    void onAniTimerTimeout();

protected:
    void closeEvent(QCloseEvent *e) override;

private:
    void addItem(const WorkerModel::WebdavCfg &cfg);
    void removeItem(int index);
    void playTrayAni();
    void stopTrayAni();

private:
    Model *m_model;
    int m_busyWorkerCount;
    QTableView *m_itemTableView;
    QStandardItemModel *m_itemTableViewModel;
    QSystemTrayIcon *m_sysTray;
    QTimer *m_trayAniTimer;
    int m_currentAniIndex;
};
#endif // MAINWINDOW_H
